function init() {
  
  userRegexp = /\buser=([^&]+)/;
  form.user.value = window.location.href.match(userRegexp)
                   ? userRegexp.exec(window.location.href)[1]
                   : "";//localStorage.getItem("username");
  taxonRegexp = /\btaxon=([^&]+)/;

  if (window.location.href.match(taxonRegexp)) {
    form.taxon.value = decodeURIComponent(taxonRegexp.exec(window.location.href)[1].replace(/\+/g, '%20'));
    /*if (form.user.value && form.taxon.value) {
      form.submit();
    }*/
  }
}

String.prototype.ucFirst = function () {
    return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
};

function trim(input) {
  if (input.value.toUpperCase() == input.value) {
    input.value = input.value.toLowerCase().ucFirst();
  }
  input.value = input.value
                          .replace(/^\s+/, "")
                          .replace(/\s+$/, "");
}

function singlify(input) {
 input.value = input.value.toLowerCase()
                          .replace(/genera/, "genus")
                          .replace(/lies$/, "lia")
                          .replace(/sses$/, "ssis")
                          .replace(/(dom|lum|order)s$/, "$1") 
                          .replace(/kingdom$/, "regnum")
                          .replace(/class$/, "classis")
                          .replace(/order$/, "ordo")
                          .replace(/family$/, "familia")
                          ;
}

function clean_input(input) {
  input.value = input.value.replace(/[\d'\[\]\.]|\b(sub|super|infra|magn|parv)?(Kingdoms?|Phylum|Phyla|Orders?|Classe?s?|Family|Families|(?!\()Genu|Speci|Unranked|regnum|ordo|classis|familia|Genera|Clade)e?s?\s/ig, " ")
                           .replace(/(?: +(?:van|le|de) |[\-\w]+ (?:&|and|\+) )*[\w\-]+,.*/ig, "")
                           .replace(/\(extinct\)/ig, "@")
                           ;
}//|\w+ (?:&|and|+) 
